import Vue from 'vue'
import Vuex from 'vuex'
import modules from './modules'
import * as types from './action-type'
import {CLEAN_REQUEST_TOKEN} from "./action-type";
Vue.use(Vuex)

const store = new Vuex.Store({
  state: { // 公共的state
    request_tokens: []
  },
  strict: true,
  modules: {
    ...modules
  },
  mutations : {
      [types.SET_REQUEST_TOKEN](state, token) {
        state.request_tokens = [...state.request_tokens, token];
      },
      [types.CLEAN_REQUEST_TOKEN](state) {
        state.request_tokens.map(fn => fn())
        state.request_tokens = [];
        console.log(state.request_tokens);
      }
  }
})

export default store
